package demo05

/**
 * @author xiaoZhao
 * @date 2022/7/1
 * @describe 混入叠加 从最后往前叠加
 */
object Test15_TraitOverlying {
  def main(args: Array[String]): Unit = {
    val student1 = new Student15
    student1.increase()

    // 钻石问题特征叠加
    val myFootBall = new MyFootBall
    println(myFootBall.describe())
  }
}

trait Ball {
  def describe(): String = "ball"
}

trait ColorBall extends Ball {
  val colorBall: String = "red"

  override def describe(): String = {
     colorBall+"-----"+super.describe()
  }
}

trait CategoryBall extends Ball{
  val categoryBall: String = "foot"

  override def describe(): String = categoryBall+"-----"+super.describe()
}

class MyFootBall extends CategoryBall with ColorBall {
  override def describe(): String = "my ball is a" + super[CategoryBall].describe()
}


trait Konwledge15 {
  var amout: Int = 0

  def increase(): Unit = {
    println("Konwledge15 increase ")
  }
}

trait Talent15 {
  def singing(): Unit

  def dancing(): Unit

  def increase(): Unit = {
    println("Talent15 increase ")
  }
}

class Student15 extends Person13 with Talent15 with Konwledge15 {
  override def singing(): Unit = println("singing")

  override def dancing(): Unit = println("singing")

  override def increase(): Unit = {
    // 返回调用的是最后一个特征对应的方法
    super.increase()

  }
}